package com.qkjia.day01;

import java.util.*;

public class Test10_NotSafe {
    public static void main(String[] args) {
        //线程不安全 无序不可重复 如何保证不可重复
        Set<String> set = new HashSet<>();
        //线程安全 效率高
        //Set<String> set = new CopyOnWriteArraySet<>();
        for (int i = 0; i <100 ; i++) {
            new Thread(()->{
                set.add(UUID.randomUUID().toString().substring(0,5));
                System.out.println(set);
            },""+i).start();
        }
    }
}
